<!DOCTYPE html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
    String host = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + "/";
%>
<html>

<head>

    <title>${titleName}TCS管理系统</title>
    <meta charset="UTF-8">
    <script type="text/javascript" src="<%=basePath%>login/css/jquery-2.1.1.min.js.js"></script>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
	<link rel="stylesheet" href="<%=basePath%>login/css/reset.css">
	<link rel="stylesheet" href="<%=basePath%>login/css/style.css" media="screen" type="text/css"/>
	<link rel="stylesheet" href="<%=basePath%>login/css/bodycss.css" media="screen" type="text/css"/>
    <script type="text/javascript" src="<%=basePath%>login/js/three.min.js"></script>
</head>
<body style="background-image: url(<%=basePath%>login/img/02.png);font-family: '微软雅黑';overflow: hidden;">
<div style="background-color: #FFFFFF;width: 100%;height: 8%;position: fixed;display: inline;">
    <div style="color:#666666;margin-top: 1.2%;margin-left: 5%;float: left;">
        <!--<img alt="" src="<%=basePath%>login/img/01.png">-->
    </div>
    <div style="color:#666666;margin-top: 1.5%;margin-left: 1%;float: left;">
        <!--<img alt="" src="<%=basePath%>login/img/04.png">-->
    </div>
    <div style="color:#666666;margin-top: 1.2%;margin-left: 1%;float: left;">
        <span style="color:#666666;font-family: sans-serif;font-size: 30px;font-family: '微软雅黑';">${titleName }TCS管理系统</span>
    </div>
</div>
<ul class="bg-bubbles"
    style="position:absolute;z-index: -1; margin-bottom: -100%">
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
</ul>

<div id="window">
    <div class="page page-front" id="image">
        <div class="page-content">

            <div class="input-row ">
                <label class="label fadeIn">用户名&nbsp;:</label>
                <input id="username" name="user_acc" id="username" type="text" class="input fadeIn delay1"/>
            </div>
            <div class="input-row">
                <label class="label fadeIn delay2">密码&nbsp;:</label> <input
                    id="password" name="user_pwq" type="text" placeholder="请输入密码"
                    autocomplete="off" onfocus="this.type='password'"
                    class="input fadeIn delay3"/>
            </div>
            <div class="input-row perspective">
<%--                <button id="submit" onclick="f1()"--%>
<%--                        onKeyUp="if(event.keyCode == 13){f1();}"--%>
<%--                        class="button load-btn fadeIn delay4">--%>
<%--                    <span class="default"><i class="ion-arrow-right-b"></i>登录</span>--%>
<%--                    <div class="load-state">--%>
<%--                        <div class="ball"></div>--%>
<%--                        <div class="ball"></div>--%>
<%--                        <div class="ball"></div>--%>
<%--                    </div>--%>
<%--                </button>--%>
                <button id="submit" class="button load-btn fadeIn delay4">
                    <span class="default"><i class="ion-arrow-right-b"></i>登录</span>
                    <div class="load-state">
                        <div class="ball"></div>
                        <div class="ball"></div>
                        <div class="ball"></div>
                    </div>
                </button>
            </div>

            <div id="title" class="input-row" style="margin-top: -9%;display: none;">
                <span class="button" id='sp1' style="background: rgba(0,0,0, 0.0) !important;"></span>
            </div>
        </div>
    </div>

</div>

<script type="text/javascript" src='<%=basePath%>login/js/jquery.js'></script>
<script type="text/javascript" src="<%=basePath%>login/js/index.js"></script>
<div style="text-align:center;"></div>
<script type="text/javascript">
    //监听回车事件
    document.onkeydown = function () {

        if (event.keyCode == 13) {
            //这里提交你的表单
            document.all('submit').click();
        }
    };

    var xmlhttp;

    function f1() {
        var nm = $("#username").val();
        var pwd = $("#password").val();
        xmlhttp = null;
        if (window.XMLHttpRequest) { // code for all new browsers
            xmlhttp = new XMLHttpRequest();
        } else if (window.ActiveXObject) { // code for IE5 and IE6
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        if (xmlhttp != null) {

            xmlhttp.onreadystatechange = jiantingguocheng;
            xmlhttp.open("POST", "${pageContext.request.contextPath}/admin/dologin?useracc=" + nm + "&userpwd=" + pwd, true);
            xmlhttp.send();
        } else {
            alert("浏览器不支持");
        }
    }

    function jiantingguocheng() {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            var result = xmlhttp.responseText;
            if (result == "1") {
                $("#title").show();
                document.getElementById("sp1").innerHTML = "<font color= red>账号或密码错误！</font>";
            } else {
                $("#title").show();
                document.getElementById("sp1").innerHTML = "<font color= green>恭喜您，登录成功！</font>";
                if (result == "2") {
                    location.href = "<%=basePath%>statichtml/admin_index.html";
                }
                if (result == "3") {
                    window.location.href = "<%=basePath%>admin/index";
                }
                /* location.href = "${pageContext.request.contextPath}/selectOrderStatisticsDataQuantity.action"; */
            }
        } else {
            $("#title").show();
            document.getElementById("sp1").innerHTML = "<font color = blue>验证中...请稍后</font>";
        }
    }
</script>
</body>

</html>
<script>
    $(function () {

        $("#submit").click(function () {
            let data = {
                useracc: $("#username").val(),
                userpwd: $("#password").val()
            }
            $.ajax({
                url: "/SbdVoip/admin/dologin",
                type: "POST",
                data: data,
                dataType: "json",
                contentType: "application/x-www-form-urlencoded",
                success: function (result) {
                    $("#title").show();
                    let sp1 = $("#sp1");
                    if (result.code !== 2000) {
                        sp1.html("<font color= red>" + result.message +"</font>")
                        return
                    }
                    sp1.html("<font color= green>恭喜您，登录成功！</font>")
                    window.location.href = "<%=basePath%>admin/index";
                }
            });
        })
    });
</script>
